﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddEdit.aspx.cs" Inherits="CardLogistics.Web.MainPage.PutOutCard.PutOutApply.AddEdit" %>
<%@ Register Src="../../../Controls/WebUserControl_Nav.ascx" TagName="WebUserControl_Nav"
    TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>半成品/成品卡申领-编辑</title>
    <link href="../../../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../../../css/selPage.css" rel="stylesheet" type="text/css" />
    <script src="../../../js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="../../../js/valReq.js" type="text/javascript"></script>
    <script src="../../../js/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../../../js/jquery.tipswindow.2.0.js" type="text/javascript"></script>
    
    <script type="text/javascript">
        function valReq(issubmit) {
            var altStr = valid_isempty('APPLYNO', '申领单号');
            //必须为字母或者数字
            altStr += valid_isnoCh('APPLYNO', '申领单号');
            altStr += valid_isempty('DemandNo', '需求单号');
            altStr += valid_isempty('CardTypeName', '卡片类型');
            altStr += valid_isempty('ApplyTotal', '申领数量');
            altStr += valid_isempty('APPLYDATE', '申领日期');
 
            if (altStr != "") {
                alert(altStr);
                return false;
            }
            if (reqNum() == "err")
                return false;
            else {
                if (issubmit == 1) {
                    if (confirm("提交后该信息进入待审批状态不可编辑,确认提交吗?") == true) {
                        return true;
                    }
                    else
                        return false;
                }
                else
                    return true;
            }
        }

        $(document).ready(function () {

            $("#DemandNo").click(function () { //选择卡片出库需求单号
                $.tipsWindow({
                    ___title: "请选择卡片出库需求单号",
                    ___content: "iframe:../../SelectPage/SelPutOutDemand.aspx",
                    ___width: "1000",
                    ___height: "500",
                    ___drag: "___boxTitle",
                    ___showbg: true
                });
            });
        });


        //校验卡片数量
        function reqNum() {
            var dnum = parseInt($("#DemTotal").val()); //需求总数
            var cnum = parseInt($("#AppedTotal").val()); //已申领数量
            var ednum = parseInt($("#hf_EditSumCard").val()); //编辑时总数
            var bcnum =document.getElementById("ApplyTotal").value; //本次申领数量
            var ynum = dnum - cnum + ednum; //本次可申领数量=需求总数-已申领数量+编辑的数量
            if (bcnum > ynum) {
                alert("当前申领数量" + bcnum + "不可大于" + ynum + ",请核对!");
                return "err";
            }
        }
    </script>
</head>
<body>
    <form id="frmFather" runat="server">
    <uc1:WebUserControl_Nav ID="WebUserControl_Nav1" runat="server" />
   <%=TitleName %> 
     <input type="hidden" id="hf_detailId" name="hf_detailId" runat="server" /><!--没用-->
     <input type="hidden" id="DemTotal" runat="server" /><!--需求总数-->
     <input type="hidden" id="AppedTotal" runat="server" /><!--已申领的数量-->
     <input type="hidden" id="hf_EditSumCard" runat="server" /><!--编辑时的数量-->
    <table class="theForm" width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td class="titleTxt">
                申领单号：
            </td>
            <td class="contentTxt">
                <input id="APPLYNO" runat="server" type="text" class="dfinputNoEmp" maxlength="15"/>
            </td>
            <td class="titleTxt">
                需求单号：
            </td>
            <td class="contentTxt">
                 <input id="DemandNo" runat="server" type="text" class="dfinputImg" maxlength="25" />
                <asp:HiddenField ID="hf_DemandId" runat="server" />
                 <asp:Button ID="BtnId" runat="server" OnClick="DemandNum_Click" Width="0px" />
            </td>
        </tr>

          <tr>
            <td class="titleTxt">
                卡片类型：
            </td>
            <td class="contentTxt">
                <input id="CardTypeName" runat="server" type="text" class="dfinputNoEmp" maxlength="25" readonly="readonly" />
                 <asp:HiddenField ID="CardTypeId" runat="server" />
            </td>
              <td class="titleTxt">
                申领数量：
            </td>
            <td class="contentTxt">
                <input id="ApplyTotal" runat="server" type="text" class="dfinputNoEmp"  onkeydown="onlyNum();" maxlength="7"  />
            </td>
        </tr>

        <tr>
            <td class="titleTxt">
                申领日期：
            </td>
            <td class="contentTxt">
                <input id="APPLYDATE" runat="server" type="text" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
            </td>
           
              <td class="titleTxt">
            </td>
            <td class="contentTxt">
            </td>
        </tr>
        
        <tr>
           <td class="titleTxt">
                备注：
            </td>
            <td colspan="5">
                <input id="REMARKS" runat="server" type="text" class="dfinput" style="width: 90%;" maxlength="200"/>
            </td>
        </tr>

        <tr class="btntr">
            <td colspan="4" align="center">
                <asp:Button ID="btn_Submit" CssClass="btn" runat="server" Text="保存并提交" OnClientClick="return valReq(1);"
                     OnClick="btn_Submit_Click"  />
                <asp:Button ID="btn_Add" CssClass="btn" runat="server" Text="保存" OnClientClick="return valReq(0);"
                 OnClick="btn_Add_Click"  />
                <input type="button" class="btn" value="返回" onclick="javascript:history.go(-1);" />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>